<?php
	/*
	print_r($hPayment);
	echo "</br></br></br></br></br></br>";
	print_r($arrDPayment);
	*/
?>
<script type="text/javascript">
	function doPrint(){
		window.print();
	}
	
	function doExport2Excel(){
		var url="index.php?r=keuangan/tu/studentPayment/paymentReceiptAsExcel&id=<?php echo $id;?>";
		var winName = "Save2Excel";
		var specs ="menubar=0,scrollbars=1,status=0,titlebar=0,toolbar=0";
		var width=900,height=500;
		var replace = false,onCenter = true;
		var w = openWindow(winName,url,width,height,onCenter,specs,replace);
		w.focus();
	}
</script>

<div style="width:900px">
	<div class="no_print" style="border-bottom:2px solid #000;padding-bottom:5px;margin-bottom:20px">
	<?php 
		$this->widget('application.components.widgets.ActionBar', 
			array("menuAlign" => "right", 
				'items' => array(
					array(
						'id' => "btnPrint",
						'title' => "Cetak",
						'icon' => "images/action/Actions-print-icon.png",
						'callback'=>"doPrint"
					),
					array(
						'id' => "btn2Excel",
						'title' => "Export to Excel",
						'icon' => "images/action/Action-excel.png",
						'callback'=>"doExport2Excel"
					),				
				)
			)
		);
	?>
	</div>
	
	<div style="width:100%;text-align:center">
		<div><label style="font-size:14px;font-weight:bold">Bukti Pembayaran</label></div>
	</div>
	
	<?php
		$widthValue = "100px"; 
	?>
	<div style="width:100%;text-align:right">
		<div>
			<label>Payment NO :</label>
			<label class="form" style="width:<?php echo $widthValue;?>"><?php echo $hPayment->payment_no; ?></label>
		</div>
		<div>
			<label>Payment Date :</label>
			<label class="form" style="width:<?php echo $widthValue;?>">
				<?php 
					echo date_format(date_create_from_format( "Y-m-d", $hPayment->payment_date),"d-M-Y");
				?>
			</label>
		</div>
	</div>
	<?php
		$widthLabel = "100px"; 
	?>
	
	<div style="width:100%">
		<div>
			<label class="form" style="width:<?php echo $widthLabel; ?>" >Student </label><label>:</label>
			<label class="form" ><?php echo $hPayment->student->sid ." - " . $hPayment->student->name ; ?></label>
		</div>
		<div>
			<label class="form" style="width:<?php echo $widthLabel; ?>" >Payment to</label><label>:</label>
			<label class="form" ><?php echo $hPayment->receiveAcc->name; ?></label>
		</div>
		<div>
			<label class="form" style="width:<?php echo $widthLabel; ?>" >Keterangan</label><label>:</label>
			<label class="form" ><?php echo $hPayment->notes; ?></label>
		</div>	
			
		<div>
			<label class="form" style="width:<?php echo $widthLabel; ?>" >Received by</label><label>:</label>
			<label class="form" ><?php echo $hPayment->user->user_name; ?></label>
		</div>	
		<style>
			table{
				margin:0px;
			}
			th{
				border:1px solid #000;
				background-color:#eeeeee;
				font-weight:bold;
				font-size:12px;
				padding:5px;
				margin:0px;
			}
			td{
				border-left:1px solid #000;
				border-bottom:1px solid #000;
				border-right:1px solid #000;
				padding:5px;
				margin:0px;
			}
			
		</style>
		<table style="width:100%;border:0px solid #000" cellpadding=0 cellspaccing=0 >
			<tr>
				<th style="width:100px">Invoice No.</th>
				<th style="width:100px">Invoice Date</th>
				<th style="text-align:center">Keterangan</th>
				<th style="width:100px;text-align:right">Total Invoice</th>
				<th style="width:100px;text-align:right">Total Payment</th>
				<th style="width:100px;text-align:right">Balance</th>
			</tr>
			<?php
				$grandTtl =0;
				foreach($arrDPayment as $dPayment){

					echo "<tr>";
						echo "<td>". $dPayment->studentInvoice->invoice_no ."</td>";
						echo "<td>". date_format(date_create_from_format( "Y-m-d", $dPayment->studentInvoice->invoice_date),"d-M-Y") ."</td>";
						echo "<td>". $dPayment->notes ."</td>";
						echo "<td style='text-align:right'>". Utils::formatCurrency($dPayment->total_invoice) ."</td>";
						echo "<td style='text-align:right'>". Utils::formatCurrency($dPayment->total_payment) ."</td>";
						$balance = $dPayment->total_invoice - $dPayment->total_payment;
						//$ttl = $dPayment->studentInvoice->ttl_invoice -  $dPayment->studentInvoice->ttl_disc;
						$grandTtl += $dPayment->total_payment;
						echo "<td style='text-align:right'>".  Utils::formatCurrency($balance) ."</td>";
					echo "</tr>";
				} 
			?>
		</table>
		
		<div style="float:left">
			<label style="font-weight:bold;font-size:12px">## <?php echo Utils::terbilang($grandTtl) ; ?> rupiah ##</label>
		</div>
		<div style="float:right;width:500px;text-align:right;">
			<label style="font-weight:bold;font-size:12px">Total Payment: Rp.  <?php echo Utils::formatCurrency($grandTtl) ; ?></label>			
		</div>
		<div style="clear:both"></div>
		
	</div>
	
	
	
</div>